<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<div>
			<span class="hour">xx</span>小时
			<span class="min">xx</span>分
			<span class="sec">xx</span>秒
		</div>
		<script type="text/javascript">
			window.addEventListener("DOMContentLoaded", function() {

			})

			var target = new Date(2022, 3, 18, 11, 40, 00);

			function ms() {
				var date = new Date();
				var td = Math.round((target.getTime() - date.getTime()) / 1000);

				var hour = parseInt(td % (60 * 60 * 24) / (60 * 60));
				var min = parseInt(td % (60 * 60) / 60);
				var sec = parseInt(td % 60);

				var h = document.querySelector(".hour");
				h.innerHTML = hour;
				var m = document.querySelector(".min");
				m.innerHTML = min;
				var s = document.querySelector(".sec");
				s.innerHTML = sec;
			}

			setInterval(ms, 1000);
		</script>
	</body>
</html>
